<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<meta name="viewport" content="width=device-width, initial-scale=1">
	<title></title>
</head>
<body>
	<script type="text/javascript">
		// 改变this的指向
		// call(this的指向，参数1，参数2) 
		// apply(this的指向，[参数1，参数2]) 
		// bind(this的指向，参数1，参数2) 需要手动调用一下()

		let obj = {
			name: "阿三",
			age:18,
			fn:function(love){
				console.log(this.name + "love" + love, this.age)
			}
		}

		let obj2 = {
			name:"阿四",
			age:66
		}
		obj.fn("蜥蜴")
		obj.fn.call(obj2, "电饭煲")//阿四love电饭煲 66
		obj.fn.apply(obj2, ["电磁炉"])//阿四love电磁卢 66
		obj.fn.bind(obj2,"微波炉")()//阿四love微波炉 66


		// 

		function Animal(name){
			this.name = name
			this.showName = function(){
				console.log(this.name)
			}
		}

		Animal.prototype.getname = function(){
			console.log("dog")
		}
		function Dog(name){
			Animal.call(this,name)
		}

		let dog = new Dog("Crazy Dog")
		dog.showName()//Crazy Dog
		// 原型上的不能继承
		// dog.geetname()报错
	</script>
</body>
</html>